﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using L = Science.Mathematics.LinearAlgebra;

namespace Strang3Ed.Chapter02.Section3
{
    public class ExampleB
    {
        public ExampleB()
        {
        }
        private string result;
        public string Result
        {
            get { return result; }
        }
        public void Compute()
        {
            double[,] x = {{1.0,0.0,0.0},
                           {-4.0,1.0,0.0},
                           {0.0,0.0,1.0}};

            L.Matrix E21 = new L.Matrix(x);

            double[,] y = {{1.0,0.0,0.0},
                           {0.0,0.0,1.0},
                           {0.0,1.0,0.0}};

            L.Matrix P32 = new L.Matrix(y);

            double[,] z = {{1.0,2.0,2.0},
                           {4.0,8.0,9.0},
                           {0.0,3.0,2.0}};

            L.Matrix A = new L.Matrix(z);

            double[] v = { 1.0, 3.0, 1.0 };

            L.Vector b = new L.Vector(v);

            L.AugmentedMatrix Ab = new L.AugmentedMatrix(A, b);


            L.Matrix P32E21Ab = P32 * (E21 * Ab);

            result += P32E21Ab[0, 0].ToString() + "    ";
            result += P32E21Ab[0, 1].ToString() + "    ";
            result += P32E21Ab[0, 2].ToString() + "    ";
            result += P32E21Ab[0, 3].ToString() + "\r\n";

            result += P32E21Ab[1, 0].ToString() + "    ";
            result += P32E21Ab[1, 1].ToString() + "    ";
            result += P32E21Ab[1, 2].ToString() + "    ";
            result += P32E21Ab[1, 3].ToString() + "\r\n";

            result += P32E21Ab[2, 0].ToString() + "    ";
            result += P32E21Ab[2, 1].ToString() + "    ";
            result += P32E21Ab[2, 2].ToString() + "    ";
            result += P32E21Ab[2, 3].ToString() + "\r\n";           
        }
    }
}
/*
1    2    2    1
0    3    2    1
0    0    1    -1
*/